<?php
/**
 * Created by Maxotm.
 * User: tuyt
 * Date: 2019/5/23
 */

namespace App\Http\Controllers;

use App\Models\Category;
use App\Models\Article;
use App\Models\Tag;
use Illuminate\Http\Request;

class CategoriesController extends Controller
{
    public function show(Category $category,Tag $tag)
    {
        // 读取分类 ID 关联的话题，并按每 20 条分页
        $articles = Article::with('user','category')->where('category_id', $category->id)->paginate(15);
        $recommend = $category->articles()->select()->limit(8)->get();
        // 传参变量话题和分类到模板中
        return view('categories.show', compact('articles', 'category','recommend'));
    }

}